package com.huxiaohui.ssbx.service.impl;

import com.huxiaohui.ssbx.service.IObjectStorageService;
import lombok.RequiredArgsConstructor;
import org.dromara.x.file.storage.core.FileInfo;
import org.dromara.x.file.storage.core.FileStorageService;
import org.springframework.stereotype.Service;


@Service
@RequiredArgsConstructor
public class ObjectStorageService implements IObjectStorageService {
    private final FileStorageService fileStorageService;

    @Override
    public String uploadBinaryAudioData(byte[] audioData, String filename) {
        FileInfo fileInfo = fileStorageService.of(audioData)
                .setPath("audio/")
                .setSaveFilename(filename)
                .upload();
        return fileInfo == null ? null : fileInfo.getUrl();
    }
}
